package experiment;

import java.io.*;
public class Memo {
    public static void main(String[] args)throws Exception {
        //创建一个文件
        File memo = new File("D:/java实验/memo.txt");
        System.out.println(memo);

        //在文件中输入内容
        if (memo.exists()) {
            System.out.println("文件存在");
        } else {
            System.out.println("文件不存在");
            memo.createNewFile();//不存在则创建
        }
        BufferedWriter output = new BufferedWriter(new FileWriter(memo, true));
        {
            output.write("456789");
            output.write("\r\n");
            output.write("213456");
            output.write("\r\n");
            output.flush();
            output.close();
        }

        //输出内容
        BufferedReader f=new BufferedReader(new FileReader(memo));
        String s=null;
        while((s=f.readLine())!=null){
            System.out.println(s);
        }
    }
}
